home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / TRUENAME.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-22  |  1KB  |  44 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 296 of 310
  3. From : Norbert Igl                         2:2402/300.3         16 Apr 93  23:32
  4. To   : Raphael Vanney                      2:320/7.0
  5. Subj : Substed drives
  6. ────────────────────────────────────────────────────────────────────────────────
  7.  > Anyone has got an idea on how to know if a drive is a real one or the
  8.  > result of a SUBST command ?
  9.  > Any help... welcome :-)
  10.  
  11.   .... it's me again .... :->
  12.  
  13.   well, DOS ( esp. COMMAND.COM ) has a undocumented Command
  14.   called TRUENAME, which takes wildcards also.
  15.  
  16.   The following is the reconstuction of this:
  17.  
  18. -------------------------8<---------------------------------}
  19. Program TrueName;
  20. uses DOS;
  21.  
  22.    function RealName(FakeName:String):String;
  23.    Var
  24.      Temp:String;
  25.      Regs:Registers;
  26.    begin
  27.      FakeName := FakeName + #0; { ASCIIZ }
  28.      With Regs do
  29.      begin
  30.        AH := $60;
  31.        DS := Seg(FakeName); SI := Ofs(FakeName[1]);
  32.        ES := Seg(Temp);     DI := OfS(Temp[1]);
  33.        INTR($21,Regs);
  34.        DOSERROR := AX * ((Flags And FCarry) shr 7);
  35.        Temp[0] := #255;
  36.        Temp[0] := CHAR(POS(#0,Temp)-1);
  37.      end;
  38.      If DosError <> 0 then Temp := '';
  39.      RealName := Temp;
  40.    end;
  41.  
  42. begin
  43.   writeln( RealName( Paramstr(1) ));
  44. end.